<template>
	<el-container>
		<el-header class='x-header'>
			<b class="title">{{ page_info.title }}</b>
			<el-button v-if="$route.query.callback_url" size="mini" icon="el-icon-back" @click="g_page.funcBack">
				返回
			</el-button>
			<ExprotExcel api_url="/xadmin/mall/mall__order_item__list/export" :api_data="form_q"></ExprotExcel>
			<!--			<el-button size="mini" type="danger" icon="el-icon-delete"-->
			<!--					   @click="g_page.funcDel()">删除-->
			<!--			</el-button>-->
			<el-button size="mini" icon="el-icon-refresh" @click="g_page.funcReload()">刷新</el-button>
		</el-header>
		<el-main class='x-main'>
			<el-form :inline="true" :model="form_q" size="mini">
				<el-form-item label="订单号">
					<el-input v-model="form_q.compOrderID" placeholder="订单号"></el-input>
				</el-form-item>
				<el-form-item label="名称">
					<el-input v-model="form_q.compName" placeholder="名称"></el-input>
				</el-form-item>
				<el-form-item label="手机号">
					<el-input v-model="form_q.compPhone" placeholder="手机号"></el-input>
				</el-form-item>
				<el-form-item label="订单状态">
					<el-select filterable clearable v-model="form_q.compState" placeholder="请选择">
						<el-option label="已支付" key="1" value="1"></el-option>
						<el-option label="未支付" key="0" value="0"></el-option>
						<el-option label="已申请退款" key="2" value="2"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="分组">
					<el-select filterable clearable v-model="form_q.compGroup" placeholder="请选择">
						<el-option v-for="(item,index) in page_info.list_group"
								   :label="item.abc_name" :key="item.abc_id+''" :value="item.abc_id+''">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="g_page.funcSearch">搜索</el-button>
				</el-form-item>
			</el-form>
			<div class="table-wrap">
				<el-table stripe ref="multipleTable" tooltip-effect="dark"
						  @selection-change="g_page.funcTableSelectionChange"
						  :data="list_data">
					<el-table-column type="selection"></el-table-column>
					<el-table-column label="订单号">
						<template slot-scope="data">
							<div v-html="data.row.moitem_morder_id"></div>
						</template>
					</el-table-column>
					<el-table-column label="购买用户">
						<template slot-scope="data">
							<div>{{ data.row.winfo_name }}</div>
							<div style="color: blue;">{{ data.row.winfo_phone }}</div>
							<div>{{ data.row.order_wxuser_id }}</div>
						</template>
					</el-table-column>
					<el-table-column label="商品分组">
						<template slot-scope="data">
							<div>{{ data.row.abc_name }}</div>
						</template>
					</el-table-column>
					<el-table-column label="商品">
						<template slot-scope="data">
							<div>{{ data.row.spu_name }}</div>
							<div>{{ data.row.spu_id }}</div>
						</template>
					</el-table-column>
					<el-table-column label="支付类型">
						<template slot-scope="data">
							{{data.row.type}}
						</template>
					</el-table-column>
					<el-table-column label="订单金额">
						<template slot-scope="data">
							{{ data.row.moitem_price }}
						</template>
					</el-table-column>
					<el-table-column label="订单状态">
						<template slot-scope="data">
							<div>{{ data.row.state }}</div>
							<div v-if="data.row.order_pay_ok==1&&data.row.order_refund==0">
								{{ data.row.order_pay_ok_date }}
							</div>
						</template>
					</el-table-column>
					<el-table-column label="下单时间">
						<template slot-scope="data">
							{{ data.row.order_create_date }}
						</template>
					</el-table-column>
					<el-table-column fixed="right" label="操作">
						<template slot-scope="data">
							<div style="font-size: 11px;" v-if="data.row.prize_deliver_no">
								<div>已发货</div>
								<div>单号：{{ data.row.prize_deliver_no }}</div>
								<div>{{ data.row.prize_deliver_date }}</div>
							</div>
							<el-button v-if="data.row.order_pay_ok==1" type="text" size="mini" @click="g_page.funcRedirectEdit(`/prize/prize__item__list?pid=${data.row.moitem_id}`)">
								查看发货情况
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<a target="_blank"></a>
			</div>
		</el-main>
		<!---->
		<!---->
		<!-- 分页 -->
		<el-footer v-if="page_show" class="x-page">
			<el-pagination class="paging" background layout="total, sizes, prev, pager, next, jumper"
						   @current-change="g_page.funcPageChange" :page-sizes="[page_size]"
						   :current-page="page_index" :page-size="page_size" :total="page_total">
			</el-pagination>
		</el-footer>
		<!---->
		<!---->
		<!-- 弹框 -->
		<el-dialog :title="form.app_idx+'配置'" :visible.sync="form_dialog_visible" width="70%">
			<el-form ref="form" :rules="form_rules" :model="form" size="mini" label-width="15%">
				<el-form-item label="入口链接" v-if="!g_page.funcIsAdminAdd()">
					<el-input :disabled="true" v-model="form.oauth_url"/>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="g_page.funcBack" size="mini">取消</el-button>
				<el-button type="success" @click="g_page.funcSave" size="mini">保存</el-button>
			</div>
		</el-dialog>
		<!---->
		<!---->
		<!---->
	</el-container>
</template>


<script>
	import ExprotExcel from '@/components/ExprotExcel'

	export default {
		components: {
			ExprotExcel
		},
		data() {
			let page_data = { super_uid: '' }
			//
			page_data = this.g_cc.funcGetInitData(page_data)
			//
			return page_data
		},
		mounted() {
			console.log('mounted')
			//
			this.g_page.funcSetVue(this)
			// 应用ID
			this.g_page.funcSetApiUrlList('/xadmin/mall/mall__order_item__list')
			// this.g_page.funcSetApiUrlDel('/xadmin/mall/mall__order_item__list/del')
			//页码
			this.g_page.funcSetPageSize(20)
			//搜索
			this.form_q = {
				'compKw': ''
			}
			this.g_page.funcGetList()
			//
			this.form_rules = {
				acc_uidX: [
					{
						required: true,
						message: '必填',
						trigger: 'blur'
					}
				]
			}
			//
		},
		methods: {
			////////////////////
			funcAdd() {
				this.g_cc.func_axios({
					url: '/xadmin/sheet/sheet__sheet__list/add',
					data: {
						loading: false
					},
					success: (res) => {
						//
						if (res.data.errcode == 0) {
							this.funcEdit({ id: res.data.id })
						} else {
							this.g_cc.func_alert(res.data.errmsg)
						}
					}
					//
				})
			}
			////////////////////
		}
	}
</script>

